<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html
    PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<!-- /fasttmp/mkdist-qt-4.3.5-1211793125/qtopia-core-opensource-src-4.3.5/src/gui/kernel/qactiongroup.cpp -->
<head>
  <title>Qt 4.3: QActionGroup Class Reference</title>
  <link href="classic.css" rel="stylesheet" type="text/css" />
</head>
<body>
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td align="left" valign="top" width="32"><a href="http://www.trolltech.com/products/qt"><img src="images/qt-logo.png" align="left" width="32" height="32" border="0" /></a></td>
<td width="1">&nbsp;&nbsp;</td><td class="postheader" valign="center"><a href="index.html"><font color="#004faf">Home</font></a>&nbsp;&middot; <a href="classes.html"><font color="#004faf">All&nbsp;Classes</font></a>&nbsp;&middot; <a href="mainclasses.html"><font color="#004faf">Main&nbsp;Classes</font></a>&nbsp;&middot; <a href="groups.html"><font color="#004faf">Grouped&nbsp;Classes</font></a>&nbsp;&middot; <a href="modules.html"><font color="#004faf">Modules</font></a>&nbsp;&middot; <a href="functions.html"><font color="#004faf">Functions</font></a></td>
<td align="right" valign="top" width="230"><a href="http://www.trolltech.com"><img src="images/trolltech-logo.png" align="right" width="203" height="32" border="0" /></a></td></tr></table><h1 align="center">QActionGroup Class Reference<br /><sup><sup>[<a href="qtgui.html">QtGui</a> module]</sup></sup></h1>
<p>The QActionGroup class groups actions together. <a href="#details">More...</a></p>
<pre> #include &lt;QActionGroup&gt;</pre><p>Inherits <a href="qobject.html">QObject</a>.</p>
<ul>
<li><a href="qactiongroup-members.html">List of all members, including inherited members</a></li>
<li><a href="qactiongroup-qt3.html">Qt 3 support members</a></li>
</ul>
<a name="properties"></a>
<h3>Properties</h3>
<ul>
<li><div class="fn"/><b><a href="qactiongroup.html#enabled-prop">enabled</a></b> : bool</li>
<li><div class="fn"/><b><a href="qactiongroup.html#exclusive-prop">exclusive</a></b> : bool</li>
<li><div class="fn"/><b><a href="qactiongroup.html#visible-prop">visible</a></b> : bool</li>
</ul>
<ul>
<li><div class="fn"/>1 property inherited from <a href="qobject.html#properties">QObject</a></li>
</ul>
<a name="public-functions"></a>
<h3>Public Functions</h3>
<ul>
<li><div class="fn"/><b><a href="qactiongroup.html#QActionGroup">QActionGroup</a></b> ( QObject * <i>parent</i> )</li>
<li><div class="fn"/><b><a href="qactiongroup.html#dtor.QActionGroup">~QActionGroup</a></b> ()</li>
<li><div class="fn"/>QList&lt;QAction *&gt; <b><a href="qactiongroup.html#actions">actions</a></b> () const</li>
<li><div class="fn"/>QAction * <b><a href="qactiongroup.html#addAction">addAction</a></b> ( QAction * <i>action</i> )</li>
<li><div class="fn"/>QAction * <b><a href="qactiongroup.html#addAction-2">addAction</a></b> ( const QString &amp; <i>text</i> )</li>
<li><div class="fn"/>QAction * <b><a href="qactiongroup.html#addAction-3">addAction</a></b> ( const QIcon &amp; <i>icon</i>, const QString &amp; <i>text</i> )</li>
<li><div class="fn"/>QAction * <b><a href="qactiongroup.html#checkedAction">checkedAction</a></b> () const</li>
<li><div class="fn"/>bool <b><a href="qactiongroup.html#enabled-prop">isEnabled</a></b> () const</li>
<li><div class="fn"/>bool <b><a href="qactiongroup.html#exclusive-prop">isExclusive</a></b> () const</li>
<li><div class="fn"/>bool <b><a href="qactiongroup.html#visible-prop">isVisible</a></b> () const</li>
<li><div class="fn"/>void <b><a href="qactiongroup.html#removeAction">removeAction</a></b> ( QAction * <i>action</i> )</li>
</ul>
<ul>
<li><div class="fn"/>29 public functions inherited from <a href="qobject.html#public-functions">QObject</a></li>
</ul>
<a name="public-slots"></a>
<h3>Public Slots</h3>
<ul>
<li><div class="fn"/>void <b><a href="qactiongroup.html#setDisabled">setDisabled</a></b> ( bool <i>b</i> )</li>
<li><div class="fn"/>void <b><a href="qactiongroup.html#enabled-prop">setEnabled</a></b> ( bool )</li>
<li><div class="fn"/>void <b><a href="qactiongroup.html#exclusive-prop">setExclusive</a></b> ( bool )</li>
<li><div class="fn"/>void <b><a href="qactiongroup.html#visible-prop">setVisible</a></b> ( bool )</li>
</ul>
<ul>
<li><div class="fn"/>1 public slot inherited from <a href="qobject.html#public-slots">QObject</a></li>
</ul>
<a name="signals"></a>
<h3>Signals</h3>
<ul>
<li><div class="fn"/>void <b><a href="qactiongroup.html#hovered">hovered</a></b> ( QAction * <i>action</i> )</li>
<li><div class="fn"/>void <b><a href="qactiongroup.html#triggered">triggered</a></b> ( QAction * <i>action</i> )</li>
</ul>
<ul>
<li><div class="fn"/>1 signal inherited from <a href="qobject.html#signals">QObject</a></li>
</ul>
<h3>Additional Inherited Members</h3>
<ul>
<li><div class="fn"/>5 static public members inherited from <a href="qobject.html#static-public-members">QObject</a></li>
<li><div class="fn"/>7 protected functions inherited from <a href="qobject.html#protected-functions">QObject</a></li>
</ul>
<a name="details"></a>
<hr />
<h2>Detailed Description</h2>
<p>The QActionGroup class groups actions together.</p>
<p>In some situations it is useful to group actions together. For example, if you have a <b>Left Align</b> action, a <b>Right Align</b> action, a <b>Justify</b> action, and a <b>Center</b> action, only one of these actions should be active at any one time. One simple way of achieving this is to group the actions together in an action group.</p>
<p>Here's a example (from the <a href="mainwindows-menus.html">Menus</a> example):</p>
<pre>     alignmentGroup = new QActionGroup(this);
     alignmentGroup-&gt;addAction(leftAlignAct);
     alignmentGroup-&gt;addAction(rightAlignAct);
     alignmentGroup-&gt;addAction(justifyAct);
     alignmentGroup-&gt;addAction(centerAct);
     leftAlignAct-&gt;setChecked(true);</pre>
<p>Here we create a new action group. Since the action group is exclusive by default, only one of the actions in the group is checked at any one time.</p>
<p align="center"><img src="images/qactiongroup-align.png" alt="Alignment options in a QMenu" /></p><p>A QActionGroup emits an <a href="qactiongroup.html#triggered">triggered</a>() signal when one of its actions is chosen. Each action in an action group emits its <a href="qactiongroup.html#triggered">triggered</a>() signal as usual.</p>
<p>As stated above, an action group is <a href="qactiongroup.html#exclusive-prop">exclusive</a> by default; it ensures that only one checkable action is active at any one time. If you want to group checkable actions without making them exclusive, you can turn of exclusiveness by calling setExclusive(false).</p>
<p>Actions can be added to an action group using <a href="qactiongroup.html#addAction">addAction</a>(), but it is usually more convenient to specify a group when creating actions; this ensures that actions are automatically created with a parent. Actions can be visually separated from each other by adding a separator action to the group; create an action and use <a href="qaction.html">QAction</a>'s <a href="qaction.html#setSeparator">setSeparator()</a> function to make it considered a separator. Action groups are added to widgets with the <a href="qwidget.html#addActions">QWidget::addActions</a>() function.</p>
<p>See also <a href="qaction.html">QAction</a>.</p>
<hr />
<h2>Property Documentation</h2>
<h3 class="fn"><a name="enabled-prop"></a>enabled : bool</h3>
<p>This property holds whether the action group is enabled.</p>
<p>Each action in the group will be enabled or disabled unless it has been explicitly disabled.</p>
<p>Access functions:</p>
<ul>
<li><div class="fn"/><b>bool isEnabled () const</b></li>
<li><div class="fn"/><b>void setEnabled ( bool )</b></li>
</ul>
<p>See also <a href="qaction.html#enabled-prop">QAction::setEnabled</a>().</p>
<h3 class="fn"><a name="exclusive-prop"></a>exclusive : bool</h3>
<p>This property holds whether the action group does exclusive checking.</p>
<p>If exclusive is true, only one checkable action in the action group can ever be active at any time. If the user chooses another checkable action in the group, the one they chose becomes active and the one that was active becomes inactive.</p>
<p>Access functions:</p>
<ul>
<li><div class="fn"/><b>bool isExclusive () const</b></li>
<li><div class="fn"/><b>void setExclusive ( bool )</b></li>
</ul>
<p>See also <a href="qaction.html#checkable-prop">QAction::checkable</a>.</p>
<h3 class="fn"><a name="visible-prop"></a>visible : bool</h3>
<p>This property holds whether the action group is visible.</p>
<p>Each action in the action group will match the visible state of this group unless it has been explicitly hidden.</p>
<p>Access functions:</p>
<ul>
<li><div class="fn"/><b>bool isVisible () const</b></li>
<li><div class="fn"/><b>void setVisible ( bool )</b></li>
</ul>
<p>See also <a href="qaction.html#enabled-prop">QAction::setEnabled</a>().</p>
<hr />
<h2>Member Function Documentation</h2>
<h3 class="fn"><a name="QActionGroup"></a>QActionGroup::QActionGroup ( <a href="qobject.html">QObject</a> * <i>parent</i> )</h3>
<p>Constructs an action group for the <i>parent</i> object.</p>
<p>The action group is exclusive by default. Call setExclusive(false) to make the action group non-exclusive.</p>
<h3 class="fn"><a name="dtor.QActionGroup"></a>QActionGroup::~QActionGroup ()</h3>
<p>Destroys the action group.</p>
<h3 class="fn"><a name="actions"></a><a href="qlist.html">QList</a>&lt;<a href="qaction.html">QAction</a> *&gt; QActionGroup::actions () const</h3>
<p>Returns the list of this groups's actions. This may be empty.</p>
<h3 class="fn"><a name="addAction"></a><a href="qaction.html">QAction</a> * QActionGroup::addAction ( <a href="qaction.html">QAction</a> * <i>action</i> )</h3>
<p>Adds the <i>action</i> to this group, and returns it.</p>
<p>Normally an action is added to a group by creating it with the group as its parent, so this function is not usually used.</p>
<p>See also <a href="qaction.html#setActionGroup">QAction::setActionGroup</a>().</p>
<h3 class="fn"><a name="addAction-2"></a><a href="qaction.html">QAction</a> * QActionGroup::addAction ( const <a href="qstring.html">QString</a> &amp; <i>text</i> )</h3>
<p>This is an overloaded member function, provided for convenience.</p>
<p>Creates and returns an action with <i>text</i>. The newly created action is a child of this action group.</p>
<p>Normally an action is added to a group by creating it with the group as parent, so this function is not usually used.</p>
<p>See also <a href="qaction.html#setActionGroup">QAction::setActionGroup</a>().</p>
<h3 class="fn"><a name="addAction-3"></a><a href="qaction.html">QAction</a> * QActionGroup::addAction ( const <a href="qicon.html">QIcon</a> &amp; <i>icon</i>, const <a href="qstring.html">QString</a> &amp; <i>text</i> )</h3>
<p>This is an overloaded member function, provided for convenience.</p>
<p>Creates and returns an action with <i>text</i> and an <i>icon</i>. The newly created action is a child of this action group.</p>
<p>Normally an action is added to a group by creating it with the group as its parent, so this function is not usually used.</p>
<p>See also <a href="qaction.html#setActionGroup">QAction::setActionGroup</a>().</p>
<h3 class="fn"><a name="checkedAction"></a><a href="qaction.html">QAction</a> * QActionGroup::checkedAction () const</h3>
<p>Returns the currently checked action in the group, or 0 if none are checked.</p>
<h3 class="fn"><a name="hovered"></a>void QActionGroup::hovered ( <a href="qaction.html">QAction</a> * <i>action</i> )&nbsp;&nbsp;<tt> [signal]</tt></h3>
<p>This signal is emitted when the given <i>action</i> in the action group is highlighted by the user; for example, when the user pauses with the cursor over a menu option, toolbar button, or presses an action's shortcut key combination.</p>
<p>See also <a href="qaction.html#activate">QAction::activate</a>().</p>
<h3 class="fn"><a name="removeAction"></a>void QActionGroup::removeAction ( <a href="qaction.html">QAction</a> * <i>action</i> )</h3>
<p>Removes the <i>action</i> from this group. The action will have no parent as a result.</p>
<p>See also <a href="qaction.html#setActionGroup">QAction::setActionGroup</a>().</p>
<h3 class="fn"><a name="setDisabled"></a>void QActionGroup::setDisabled ( bool <i>b</i> )&nbsp;&nbsp;<tt> [slot]</tt></h3>
<p>This is a convenience function for the <a href="qactiongroup.html#enabled-prop">enabled</a> property, that is useful for signals--slots connections. If <i>b</i> is true the action group is disabled; otherwise it is enabled.</p>
<h3 class="fn"><a name="triggered"></a>void QActionGroup::triggered ( <a href="qaction.html">QAction</a> * <i>action</i> )&nbsp;&nbsp;<tt> [signal]</tt></h3>
<p>This signal is emitted when the given <i>action</i> in the action group is activated by the user; for example, when the user clicks a menu option, toolbar button, or presses an action's shortcut key combination.</p>
<p>Connect to this signal for command actions.</p>
<p>See also <a href="qaction.html#activate">QAction::activate</a>().</p>
<p /><address><hr /><div align="center">
<table width="100%" cellspacing="0" border="0"><tr class="address">
<td width="30%">Copyright &copy; 2008 <a href="trolltech.html">Trolltech</a></td>
<td width="40%" align="center"><a href="trademarks.html">Trademarks</a></td>
<td width="30%" align="right"><div align="right">Qt 4.3.5</div></td>
</tr></table></div></address></body>
</html>
